home *** CD-ROM | disk | FTP | other *** search
- RCS_ID_C "$Id: keymap.c,v 0.3 1993/03/29 07:49:29 ppessi Exp $";
- /*
- * Find a named keymap
- * If named keymap can not be found, load it from disk
- *
- * $Author: ppessi $ $Revision: 0.3 $ $Date: 1993/03/29 07:49:29 $
- */
-
- #include "devices/keymap.h"
- #include "clib/keymap_protos.h"
- #include "clib/exec_protos.h"
-
- #ifdef __SASC
- #include <pragmas/keymap_pragmas.h>
- #endif
-
- #include <exec/types.h>
- #include <libraries/dos.h>
- #include <clib/dos_protos.h>
- #include <string.h>
- #include <stdio.h>
-
- #define UNLESS(x) if(!(x))
- #define UNTIL(x) while(!(x))
-
- char keyMapDir[] = "Devs:keymaps/";
- #define MAXKEYMAPLEN 20
-
- struct KeyMap *
- FindKeyMap(char * keyMapName)
- {
- struct KeyMapResource *keyMapBase;
- struct KeyMapNode *keymap_n;
- BPTR keySegs;
- char fullKeyMapName[sizeof(keyMapDir)+MAXKEYMAPLEN];
-
- UNLESS(keyMapBase=(struct KeyMapResource *)OpenResource("keymap.resource"))
- return NULL;
-
- /* Is it already loaded? */
- keymap_n = FindName(&(keyMapBase->kr_List), keyMapName);
- if (!keymap_n) {
- /* Not found, we load it from devs:keymaps */
- strcpy(fullKeyMapName, keyMapDir);
- strncat(fullKeyMapName, keyMapName, MAXKEYMAPLEN);
- keySegs = LoadSeg(fullKeyMapName);
- if (!keySegs)
- return NULL;
- keymap_n = (struct KeyMapNode *)((LONG *) (keySegs << 2) + 1);
- AddHead(&(keyMapBase->kr_List), (struct Node *)keymap_n);
- }
- return &(keymap_n->kn_KeyMap);
- }
-
-
-
-